unit Workdlg;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, StdCtrls, Buttons, ComCtrls;

type
  TFormWorking = class(TForm)
    BBAbort: TBitBtn;
    LMessage: TLabel;
    Animate: TAnimate;
    procedure FormKeyPress(Sender: TObject; var Key: Char);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure Show( title,message: string; OnAbort: TNotifyEvent );
  end;

var
  FormWorking: TFormWorking= nil;

procedure BeginWork(title,message: string; OnAbort: TNotifyEvent=nil );
procedure EndWork;

implementation

{$R *.DFM}
{$R WRKDLG.RES}

procedure BeginWork(title,message: string; OnAbort: TNotifyEvent=nil );
begin
  if FormWorking=nil then FormWorking := TFormWorking.Create(Application);
  FormWorking.Show(title,message,OnAbort);
end;

procedure EndWork;
begin
  if FormWorking=nil then exit;
  FreeAndNil(FormWorking);
end;

procedure TFormWorking.Show( title,message: string; OnAbort: TNotifyEvent );
begin
  Caption := title;
  LMessage.Caption := message;
  BBAbort.Enabled := assigned(OnAbort);
  BBAbort.OnClick := OnAbort;
  Animate.Active := true;
  inherited Show;
end;

procedure TFormWorking.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if (Key=#27) and BBAbort.Enabled then BBAbort.OnClick(Sender);
end;

procedure TFormWorking.FormCreate(Sender: TObject);
begin
  Animate.ResName := 'RELOJ';
end;

end.
